from mcp.server.fastmcp import FastMCP
import json

mcp = FastMCP(name="MCP Server")


@mcp.resource("config://settings", mime_type="application/json")
def get_settings() -> str:
    return json.dumps(
        {"theme": "dark", "language": "zh-CN"}, ensure_ascii=False, indent=2
    )


@mcp.resource("greeting://{name}", mime_type="text/plain")
def greeting(name: str) -> str:
    return f"Hello,{name}"


@mcp.resource("user://{id}", mime_type="text/plain")
def greeting(id: str) -> str:
    if id == "001":
        return "用户001 Alice"
    elif id == "002":
        return "用户002 Bob"
    else:
        return f"未找到用户{id}"


if __name__ == "__main__":
    mcp.run(transport="stdio")
